package com.da.landlord;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.googlecode.cswish.annotation.cm;
import com.ra.landlord.FeeRuleCfg;

/**
 * 具体收费项
 * 1.如何产生收费项?
 * 	房租的产生:根据日期来判断是否需要产生一条房租收费项。(最近,类型为房租的item的结束时间段-(提前多少天收箐)<当前日期-->则说明要需要产生一条房租收费项)
 *  水费电费：()进入页面 时，根据FeeRule对应的水费或电费的List<mater>，然后与最近一次仪表费用的DachargeItem的meter2进行比较，比果抄表时间与本次一样，则不产生费用，否则产生可能是多条item记录。
 * @author Peter.Z
 *
 */
@Entity
@Table(name="da_dachargeitem")
public class DaChargeItem {
	
	@cm("未支付")
	public final static Integer STATUS_CONFIRMED = 0;
	
	@cm("已支付")
	public final static Integer STATUS_PAID = 1;
	
	//待确认，生成收租单后再产生的费用都是待确认的
	public final static Integer STATUS_NEED_CONFIRM = 2;
	
	public static final Integer CHARGE_TYPE_RENTAL = 0;			//房租
	public static final Integer CHARGE_TYPE_DEPOSIT = 1;		//押金
	public static final Integer CHARGE_TYPE_METER = 2;			//仪表费用
	public static final Integer CHARGE_TYPE_FIXED = 3;			//固定费用
	public static final Integer CHARGE_TYPE_BACK_DEPOSIT = 4;	//押金（退租）
	public static final Integer CHARGE_TYPE_CUSTOM = 5;			//自定义费用
	
	private Integer id;
	
	private DaChargeBillRecord chargeBillRecord;
	
	@cm("费用所对应的房问")
	private DaRoom room;
	
	@cm("分摊费用时候，记录主表")
	private DaSuite suite;
	
	@cm("上一次刻度")
	private DaMeter meter1;
	
	@cm("当前刻度")
	private DaMeter meter2;
	
	@cm("所属帐单")
	private DaChargeBill chargeBill;
	
	@cm("收费名称")
	private String name;
	
	@cm("收费依据 ")
	private DaFeeRule feeRule;
	
	@cm("收费依据 ")
	private FeeRuleCfg feeRuleCfg;
	
	@cm("时间段开始")
	private Date dateBeginRecv;
	
	@cm("时间段结束") 
	private Date dateEndRecv;
	
	@cm("实收多少")
	private BigDecimal priceActual;
	
	@cm("应收多少")
	private BigDecimal priceRecv;
	
	@cm("费用类型 0房租  1自定义费用  2仪表费用  3固定费用")
	private Integer chargeType;
	
	
	@cm("表示是否已交费     状态为0 表示此表费用未交费   1表示已交")
	private Integer status;
	
	private Date createChargeTime;
	
	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	
	@ManyToOne(fetch=FetchType.LAZY)
	public DaMeter getMeter1() {
		return meter1;
	}

	public void setMeter1(DaMeter meter1) {
		this.meter1 = meter1;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	public DaMeter getMeter2() {
		return meter2;
	}

	public void setMeter2(DaMeter meter2) {
		this.meter2 = meter2;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	public DaFeeRule getFeeRule() {
		return feeRule;
	}

	public void setFeeRule(DaFeeRule feeRule) {
		this.feeRule = feeRule;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public BigDecimal getPriceActual() {
		return priceActual;
	}

	public void setPriceActual(BigDecimal priceActual) {
		this.priceActual = priceActual;
	}

	public BigDecimal getPriceRecv() {
		return priceRecv;
	}

	public void setPriceRecv(BigDecimal priceRecv) {
		this.priceRecv = priceRecv;
	}

	@ManyToOne
	public DaChargeBill getChargeBill() {
		return chargeBill;
	}

	public void setChargeBill(DaChargeBill chargeBill) {
		this.chargeBill = chargeBill;
	}

	public Integer getChargeType() {
		return chargeType;
	}
	
	public void setChargeType(Integer chargeType) {
		this.chargeType = chargeType;
	}

	public Date getDateBeginRecv() {
		return dateBeginRecv;
	}

	public void setDateBeginRecv(Date dateBeginRecv) {
		this.dateBeginRecv = dateBeginRecv;
	}

	public Date getDateEndRecv() {
		return dateEndRecv;
	}

	public void setDateEndRecv(Date dateEndRecv) {
		this.dateEndRecv = dateEndRecv;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	public DaRoom getRoom() {
		return room;
	}

	public void setRoom(DaRoom room) {
		this.room = room;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	public DaSuite getSuite() {
		return suite;
	}

	public void setSuite(DaSuite suite) {
		this.suite = suite;
	}

	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreateChargeTime() {
		return createChargeTime;
	}

	public void setCreateChargeTime(Date createChargeTime) {
		this.createChargeTime = createChargeTime;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	public DaChargeBillRecord getChargeBillRecord() {
		return chargeBillRecord;
	}

	public void setChargeBillRecord(DaChargeBillRecord chargeBillRecord) {
		this.chargeBillRecord = chargeBillRecord;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	public FeeRuleCfg getFeeRuleCfg() {
		return feeRuleCfg;
	}

	public void setFeeRuleCfg(FeeRuleCfg feeRuleCfg) {
		this.feeRuleCfg = feeRuleCfg;
	}
	
	
}
